import request from '@/utils/request'
import type { TradeMarkResponseData, TradeMark } from './type'

const API = {
  TRADEMARK_URL: '/admin/product/baseTrademark/',
  ADDTRADEMARK_URL: '/admin/product/baseTrademark/save',
  UPDATETRADEMARK_URL: '/admin/product/baseTrademark/update',
  DELETETRADEMARK_URL: '/admin/product/baseTrademark/remove',
}

export const reqHasTrademark = async (page: number, limit: number) => {
  return await request.get<any, TradeMarkResponseData>(
    API.TRADEMARK_URL + `${page}/${limit}`,
  )
}

export const reqAddOrUpdateTrademark = async (data: TradeMark) => {
  if (data.id) {
    return await request.put<any, any>(API.UPDATETRADEMARK_URL, data)
  } else {
    return await request.post<any, any>(API.ADDTRADEMARK_URL, data)
  }
}

export const reqDeleteTrademark = async (id: string) => {
  return await request.delete<any, any>(API.DELETETRADEMARK_URL + '/' + id)
}
